/* Variables globales */
var cont=0;
var n_fila;
var muestra;
/*                  */


function makeArray(n){
    this.length = n;
    for (i=1;i<=n;i++){
        this[i]=0;
    }
    return this;
}

function Muestrafecha() {
    var meses = new makeArray(12);
    meses[0]  = "Enero";
    meses[1]  = "Febrero";
    meses[2]  = "Marzo";
    meses[3]  = "Abril";
    meses[4]  = "Mayo";
    meses[5]  = "Junio";
    meses[6]  = "Julio";
    meses[7]  = "Agosto";
    meses[8]  = "Septiembre";
    meses[9]  = "Octubre";
    meses[10] = "Noviembre";
    meses[11] = "Deciembre";

    var dias_de_la_semana = new makeArray(7);
    dias_de_la_semana[0]  = "Domingo";
    dias_de_la_semana[1]  = "Lunes";
    dias_de_la_semana[2]  = "Martes";
    dias_de_la_semana[3]  = "Mi\u00e9rcoles";
    dias_de_la_semana[4]  = "Jueves";
    dias_de_la_semana[5]  = "Viernes";
    dias_de_la_semana[6]  = "S\u00e1bado";

    var today = new Date();
    var day   = today.getDate();
    var month = today.getMonth();
    var year  = today.getYear();
    var dia = today.getDay();
  
    if (year < 1000) {
        year += 1900;
    }
	   
    return(dias_de_la_semana[dia] + ", " + day + " de " + meses[month] + " del " + year);
}


function agregarFila(form) {
    
    refForm = document.getElementById(form);
    
    if(refForm && confirm("¿Desea agregar una nueva fila?")) {
        n_fila='fila'+cont;
        cont++;
        refTabla = document.getElementById("tabla_medicamentos");
        nFilas = refTabla.getElementsByTagName("TR").length;
        nuevaFila = refTabla.insertRow(nFilas);//nFilas -1
        nuevaFila.setAttribute("id", n_fila);
	
        nuevaCelda = nuevaFila.insertCell(0);
        nuevaCelda.innerHTML = " <ul> <li id='' class='formato_letra'> <span>" + 
        "<input id='f" + String(nFilas -2) + "c0' name='' type='text' class='field text fn' value='' size='15' maxlength='255' tabindex='1' />"+
        "</span>  </li> </ul>"
        nuevaCelda = nuevaFila.insertCell(1);
        nuevaCelda.innerHTML = "<ul> <li id='' class='formato_letra'> <span>" + 
        "<input id='f" + String(nFilas -2) + "c1' name='' type='text' class='field text fn' value='' size='15' maxlength='255' tabindex='1' />"+
        "</span>  </li> </ul> "
        nuevaCelda = nuevaFila.insertCell(2);
        nuevaCelda.innerHTML = "<ul> <li id='' class='formato_letra'> <span> " + 
        "<textarea  id='f" + String(nFilas -2) + "c2' name='' spellcheck='true'  rows='2' cols='13' tabindex='1' class='textarea'> </textarea>"+ 
        "</span>  </li> </ul> "
        nuevaCelda = nuevaFila.insertCell(3);       
        nuevaCelda.innerHTML =  "<a title='Agregar fila'  class='agregar-eliminar'> <span> <img src='img/boton-agregar.gif' alt='agregar una fila'  onclick='agregarFila("+'&apos;registro_examen&apos;'+");'> </img> </span> </a>" +
                                "<a title='Eliminar fila' class='agregar-eliminar'><span> <img src='img/boton-remover.gif' alt='eliminar una fila'  onclick='borrarFila(&apos;"+n_fila+"&apos;);'> </img> </span> </a>"
  }                            
   
}

function borrarFila(idFila){ 
    if(confirm("¿Desea eliminar la fila seleccionada?")){
        var element = document.getElementById(idFila); 
        var padre = element.parentNode;
        padre.removeChild(element);
    }
        
}

function cerrar_sesion(){
    if (confirm ("¿Realmente desea cerrar la sesión?"))
    {
        document.location="/SAPCOMED/CerrarSesion.jsp";	
    }	
}


/*text sizer*/

/*------------------------------------------------------------
	Document Text Sizer- Copyright 2003 - Taewook Kang.  All rights reserved.
	Coded by: Taewook Kang (txkang.REMOVETHIS@hotmail.com)
	Web Site: http://txkang.com
	Script featured on Dynamic Drive (http://www.dynamicdrive.com)
	
	Please retain this copyright notice in the script.
	License is granted to user to reuse this code on 
	their own website if, and only if, 
	this entire copyright notice is included.
--------------------------------------------------------------*/

//Specify affected tags. Add or remove from list:
var tgs = new Array( 'h1','h2','p');

//Specify spectrum of different font sizes:
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 2;

function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 6 ) sz = 6;
	startSz = sz;
		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}
